package edu.biwu;

import jakarta.servlet.*;
import jakarta.servlet.http.*;
import jakarta.servlet.annotation.*;

import java.io.IOException;

@WebServlet(value = "/config02",
        initParams =
        @WebInitParam(name = "charset", value = "UTF-8"))
/**
*  initParams = @WebInitParam(name="charset",value = "UTF-8")
*  相当于:
*     <init-param>
*            <param-name>charset</param-name>
*            <param-value>UTF-8</param-value>
*        </init-param>
*/
public class ServletConfigDemo02 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ServletConfig servletConfig = getServletConfig();
        System.out.println(servletConfig.getInitParameter("charset"));
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
